//package com.inspur.edp.cef.generator.coreGenerator.base.serializer.nestedserialize;
//
//import com.fasterxml.jackson.core.JsonGenerator;
//import com.fasterxml.jackson.databind.SerializerProvider;
//import com.inspur.edp.caf.generator.baseInfo.ParameterInfo;
//import com.inspur.edp.caf.generator.baseInfo.TypeInfo;
//import com.inspur.edp.caf.generator.method.ClassMethodGenerator;
//import com.inspur.edp.cef.designtime.api.IGspCommonField;
//import com.inspur.edp.cef.designtime.api.element.GspElementObjectType;
//import com.inspur.edp.cef.generator.coreGenerator.base.entityGenerator.CefDataTypeImplGeneratorContext;
//import com.inspur.edp.cef.generator.coreGenerator.base.serializer.SerItemGenUtil;
//import com.inspur.edp.cef.generator.coreGenerator.base.serializer.WriteEntityBasicInfoGenerator;
//import com.inspur.edp.cef.generator.overall.Utils;
//import java.util.ArrayList;
//import java.util.Arrays;
//import org.eclipse.jdt.core.dom.Block;
//import org.eclipse.jdt.core.dom.CastExpression;
//import org.eclipse.jdt.core.dom.MethodInvocation;
//import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword;
//import org.eclipse.jdt.core.dom.Statement;
//import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
//import org.eclipse.jdt.core.dom.VariableDeclarationStatement;
//
////  void writeAssociationInfo(JsonGenerator jsonGenerator, Object info, SerializerProvider serializerProvider);
//public class EnrichedWriteMethodGenerator extends ClassMethodGenerator {
//
//  private static final String paramWriter = "writer";
//  private static final String paramInfo = "info";
//  private static final String paramSerializer = "serializer";
//  private static final String paramConcreteInfo = "someInfo";
//  private final IGspCommonField field;
//  private final CefDataTypeImplGeneratorContext dataTypeGenContext;
//
//  public EnrichedWriteMethodGenerator(CefDataTypeImplGeneratorContext dataTypeGenContext,
//      IGspCommonField field) {
//    this.field = field;
//    this.dataTypeGenContext = dataTypeGenContext;
//  }
//
//  @Override
//  protected Block buildMethodBody() {
//    Block block = ast.newBlock();
//
//    block.statements().add(getCast2ConcreteInfo());
//
//    ArrayList<Statement> statements = new ArrayList<>();
//    for (IGspCommonField gspCommonField :
//        field.getChildAssociations().get(0).getRefElementCollection()) {
//      // TODO 后续支持带出字段是关联
//      if (gspCommonField.getIsFromAssoUdt()
//          || gspCommonField.getObjectType() == GspElementObjectType.Association
//          || gspCommonField.getObjectType() == GspElementObjectType.DynamicProp) {
//        continue;
//      }
//      writeEnrichedValue(statements, gspCommonField);
//    }
//    block.statements().addAll(statements);
//
//    return block;
//  }
//
//  private VariableDeclarationStatement getCast2ConcreteInfo() {
//    String enrichedInfoType = dataTypeGenContext.dataType.getGeneratedEntityClassInfo()
//        .getClassNamespace().concat(".").concat(SerItemGenUtil.getAssociationTypeName(field));
//    VariableDeclarationFragment infoDeclarationFragement = ast.newVariableDeclarationFragment();
//    CastExpression castExpression = ast.newCastExpression();
//    castExpression.setType(ast.newSimpleType(ast.newName(enrichedInfoType)));
//    castExpression.setExpression(ast.newSimpleName(paramInfo));
//    infoDeclarationFragement.setInitializer(castExpression);
//    infoDeclarationFragement.setName(ast.newSimpleName(paramConcreteInfo));
//    VariableDeclarationStatement infoDeclaration = ast
//        .newVariableDeclarationStatement(infoDeclarationFragement);
//    infoDeclaration.setType(ast.newSimpleType(ast.newName(enrichedInfoType)));
//    return infoDeclaration;
//  }
//
//  private void writeEnrichedValue(ArrayList<Statement> statements,
//      IGspCommonField refElement) {
//    MethodInvocation getValueInvocation = ast.newMethodInvocation();
//    getValueInvocation.setName(ast.newSimpleName("get" + refElement.getLabelID()));
//    getValueInvocation.setExpression(ast.newSimpleName(paramConcreteInfo));
//    WriteEntityBasicInfoGenerator
//        .writeElementGen(ast, refElement, statements, dataTypeGenContext, getValueInvocation);
//  }
//
//  @Override
//  protected String getMethodName() {
//    return "writeAssociationInfo";
//  }
//
//  @Override
//  protected TypeInfo getReturnType() {
//    return new TypeInfo("void");
//  }
//
//  @Override
//  protected boolean getIsOverride() {
//    return true;
//  }
//
//  @Override
//  protected ArrayList<ModifierKeyword> getAccessModifiers() {
//    return new ArrayList<>(
//        Arrays.asList(new ModifierKeyword[]{ModifierKeyword.PUBLIC_KEYWORD}));
//  }
//
//  @Override
//  protected ArrayList<ParameterInfo> getParameterCollection() {
//    return new ArrayList(java.util.Arrays.asList(
//        new ParameterInfo[]{
//            new ParameterInfo() {{
//              setParamType(Utils.createTypeInfo(JsonGenerator.class));
//              setParamName(paramWriter);
//            }},
//            new ParameterInfo() {{
//              setParamType(Utils.createTypeInfo(Object.class));
//              setParamName(paramInfo);
//            }},
//            new ParameterInfo() {{
//              setParamType(Utils.createTypeInfo(SerializerProvider.class));
//              setParamName(paramSerializer);
//            }}
//        }));
//  }
//}
